package cn.yunhe.service.impl;

import cn.yunhe.dao.HouseDao;
import cn.yunhe.model.House;
import cn.yunhe.service.HouseBiz;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/*spring注解*/
@Service(value = "houseBiz")
public class HouseBizImpl implements HouseBiz {

    /*spring注解*/
    @Autowired
    @Qualifier(value = "houseDao")
    private HouseDao houseDao;

    @Override
    public Page<House> searchHouse(Map<String, Object> objectMap) {
        Page page=new Page();
        //page.setTotal(houseDao.getTotalRecords(objectMap));
        //使用分页助手,实质是拦截器
        page=PageHelper.startPage((int)objectMap.get("pageNum"),(int)objectMap.get("pageSize"));
        List<House>houseList=houseDao.searchByConditions(objectMap);
        //多条件查询的房屋信息列表
        System.out.println("page====="+page);
        System.out.println("page.getResult====="+page.getResult());
        PageInfo pageInfo=new PageInfo(houseList);
        System.out.println("pageInfo.getList()====="+pageInfo.getList());
        return page;
    }

   /* public HouseDao getHouseDao() {
        return houseDao;
    }

    public void setHouseDao(HouseDao houseDao) {
        this.houseDao = houseDao;
    }*/
}
